package com.atguigu.search.controller;


import com.atguigu.common.to.es.SpuUpTo;
import com.atguigu.search.service.SearchSaveService;
import com.atguigu.search.vo.SearchParam;
import com.atguigu.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

@Controller
public class SearchProductController {
    @Autowired
    private SearchSaveService searchSaveService;

    @GetMapping("/list.html")
    public String list(SearchParam param, Model model,HttpServletRequest request){
        param.set_queryString(request.getQueryString());
        SearchResult result = searchSaveService.search(param);

        model.addAttribute("result",result);

        return "list";
    }
}
